// Class Declarations for ListOfContracts
// File: ch8list1.h
#ifndef LIST1_H
#define LIST1_H
#include "contrct2.h" // Uses the modified version of the contract class.
const int MAX_CONTRACTS = 5; // arbitrary number chosen for test purposes
typedef Contract ContractArray[MAX_CONTRACTS];
class ListOfContracts
{public:
ListOfContracts();
/*
Purpose: To instantiate (create) an instance of the class 'ListOfContracts'.
Goal: A new instance of class 'ListOfContracts' now exists
Receives: NONE
RETURNS: NONE
*/
void Add(Contract contract);
/*
Purpose: To add an instance of the class 'Contract' to the list.
Goal: A new instance of class 'contract' is on the list
Receives: a contract
Returns: NONE:
*/
void Delete(int contractNum);
/*
Purpose: To delete an instance of the class 'Contract' from the list.
Goal: The instance of class 'contract' is deleted
Receives: A contract number
Returns: NONE:
*/
bool FindContract(int ID, Contract& contract);
/*
Purpose: To find out if a contract is in the list and, if so, return it
Goal: If the list holds a contract with id 'ID', the function
returns that contract in the variable 'contract' and
the function returns true
If not, the function returns false and 'contract' holds garbage.'
Receives: A contract ID
Returns: Whether or not the contract was found AND, if found, the
contract itself.
*/
void ReplaceContract (Contract contract);
/*
Purpose: To replace the properties of one contract in the list
Goal: The properties of the contract in the list with the ID of
'contract' have been replaced
Receives: A contract
Returns: NONE
*/
void DisplayAll();
/*
Purpose: To display all the contracts in the list
Goal: All the contracts are displayed on the screen
Receives: NONE
Returns: NONE
*/
private:
int numContracts; // indicates next available slot in list
ContractArray listOfContracts;
};
#endif